import AsyncStorage from '@react-native-community/async-storage';
import { STORAGE_KEY_AGREEMENT } from '../constant';

let hasShowAgreement = false; // 是否展示过用户协议弹窗

AsyncStorage.getItem(STORAGE_KEY_AGREEMENT).then((res: any): void => {
  if (res) {
    const hasShown = JSON.parse(res);
    hasShowAgreement = hasShown;
  }
});

export const setHasShowAgreement = (): void => {
  hasShowAgreement = true;
  AsyncStorage.setItem(STORAGE_KEY_AGREEMENT, JSON.stringify(true));
};

export const getHasShowAgreement = (): boolean => {
  return hasShowAgreement;
};
